package com.atguigu.gmall.product.controller;


import com.atguigu.gmall.common.result.Result;
import com.atguigu.gmall.product.model.BaseTrademark;
import com.atguigu.gmall.product.model.CategoryTrademarkVo;
import com.atguigu.gmall.product.service.BaseTrademarkService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.atguigu.gmall.product.service.BaseCategoryTrademarkService;

import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 分类品牌中间表 前端控制器
 *
 * @author atguigu
 * @since 2023-04-18
 */
@Api(tags = "分类品牌中间表控制器")
@RestController
@RequestMapping("/admin/product") //TODO 填写基础映射URL
public class BaseCategoryTrademarkController {

    @Autowired
    private BaseCategoryTrademarkService baseCategoryTrademarkService;
    
    @Autowired
    private BaseTrademarkService baseTrademarkService;
    
    /**
     * 根据param查询品牌列表
     * @param category3Id
     * @return
     */
    @GetMapping("/baseCategoryTrademark/findTrademarkList/{category3Id}")
    public Result baseCategorTrademark (@PathVariable Long category3Id) {
        List<BaseTrademark> list = baseCategoryTrademarkService.baseCategorTrademark(category3Id);
        return Result.ok(list);
    }
    
    /**
     * 查询未关联的品牌列表
     * @param category3Id
     * @return
     */
    @GetMapping("/baseCategoryTrademark/findCurrentTrademarkList/{category3Id}")
    public Result getCurrentTrademarkList(@PathVariable Long category3Id) {
        List<BaseTrademark> list = baseCategoryTrademarkService.getCurrentTrademarkList(category3Id);
        return Result.ok(list);
    }
    
    /**
     * 关联品牌列表
     * @param categoryTrademarkVo
     * @return
     */
    @PostMapping("/baseCategoryTrademark/save")
    public Result saveBase(@RequestBody CategoryTrademarkVo categoryTrademarkVo) {
        baseCategoryTrademarkService.saveBase(categoryTrademarkVo);
        return Result.ok();
    }
    
    /**
     * 删除关联品牌
     * @param category3Id
     * @param trademarkId
     * @return
     */
    @DeleteMapping("/baseCategoryTrademark/remove/{category3Id}/{trademarkId}")
    public Result deleteBaseCate(@PathVariable Long category3Id,
                                 @PathVariable Long trademarkId) {
        baseCategoryTrademarkService.deleteBaseCate(category3Id,trademarkId);
        return Result.ok();
    }
}
